package belf.migrate.core.util;

import java.io.File;

/**
 * 方便的工具类，用于读各种配置文件。首先找系统变量“BELF_HOME”，没有设置“BELF_HOME”就从当前工作目录找。
 */
public class ConfigUtil {
    public static final String BELF_HOME = "BELF_HOME";

    public static String getConfigDir() {
        return getBelfHome() + File.separator + "conf";
    }

    public static String getTaskDir() {
        return getBelfHome() + File.separator + "conf" + File.separator + "task";
    }

    public static String getJobDir() {
        return getBelfHome() + File.separator + "conf" + File.separator + "job";
    }

    public static String getDBTypeMappingDir() {
        return getBelfHome() + File.separator + "conf" + File.separator + "db-type-mapping";
    }

    public static String getDBFunctionMappingDir() {
        return getBelfHome() + File.separator + "conf" + File.separator + "db-function-mapping";
    }

    public static String getDBFieldConvertDir() {
        return getBelfHome() + File.separator + "conf" + File.separator + "db-field-convert";
    }

    public static String getDBTypesDir() {
        return getBelfHome() + File.separator + "conf" + File.separator + "db-types";
    }

    public static String getBelfHome() {
        String belfHome = System.getenv(BELF_HOME);
        if (null == belfHome) {
            belfHome = System.getProperty("user.dir");
        }
        return belfHome;
    }
}
